package com.coderliu.proxy.dynamicproxy;

import com.coderliu.proxy.interfaces.Proxyinterface;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;


/**
 * 动态代理
 */
public class DynamicProxy implements InvocationHandler  {

    //真实的代理对象
    private Object proxy;

    //构造方法给初始值
    public DynamicProxy(Object proxy) {
        this.proxy = proxy;
    }

    @Override
    public Object invoke(Object abc, Method method, Object[] args) throws Throwable {
        System.out.println("方法前置");
        method.invoke(proxy,args);
        System.out.println("方法后置");

        return null;
    }
}
